package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
//签到表
public class Signin extends BaseDomain{
    private Long userId;//用户id
    private Integer days;//连续签到天数
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date time;//签到时间
    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("userId",userId);
        map.put("days",days);
        map.put("time",new SimpleDateFormat("yyyy-MM-dd").format(time));
        return JSONUtil.toJSONString(map);
    }
}